package com.blame.springblog.controller;


import com.blame.springblog.pojo.dataobject.UserInfo;
import com.blame.springblog.pojo.request.UserLoginRequest;
import com.blame.springblog.pojo.response.BlogInfoResponse;
import com.blame.springblog.pojo.response.UserInfoResponse;
import com.blame.springblog.pojo.response.UserLoginResponse;
import com.blame.springblog.service.BlogInfoService;
import com.blame.springblog.service.UserInfoService;
import com.blame.springblog.service.impl.BlogInfoServiceImpl;
import com.blame.springblog.service.impl.UserInfoServiceImpl;
import jakarta.annotation.Resource;
import jakarta.validation.constraints.NotNull;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/user")
public class UserInfoController {

    @Resource(name = "userInfoServiceImpl")
    private UserInfoService userInfoService;




    @RequestMapping("/login")
    public UserLoginResponse userLogin(@RequestBody @Validated UserLoginRequest userLoginRequest){
        log.info("用户登录  用户："+userLoginRequest.getUserName());
        return userInfoService.userLogin(userLoginRequest);
    }

    @RequestMapping("/getUserInfo")
    public UserInfoResponse getUserInfo(@NotNull(message = "userId不能为空") Integer userId){
        return userInfoService.getUserInfo(userId);
    }

    @RequestMapping("/getAuthorInfo")
    public UserInfoResponse getBlogInfo(@NotNull(message = "blogId不能为空") Integer blogId){
        return userInfoService.getAuthorId(blogId);
    }

}
